Repository navigation
feat(tree): 项目树与提交文件树支持紧凑显示单一子文件夹链 - #257
Conversation
- workspace.projectTree.rows 新增可选 compact:已列出、只含一个子文件夹的非根文件夹与子文件夹合成一行(同 IDEA/VS Code),返回 heads 给出每行链首;选区与 top 落在链中文件夹时移到该行。
- git.changedFileGroups 新增可选 nest{compact}:按树列出全部上级文件夹并给出 depth 与 label,compact 时把无文件且只含一个文件夹的链合并,label 用 / 连接。
- 两个 fixture 增加对应用例,rust-core-api.md 补充契约。
- 顺手修 name_ranking.rs 的 clippy question_mark(#255 引入)。
Refs 1lck/Lithe-IDEA#2641
紧凑链无论多长只占一层缩进;链下的文件和文件夹要跟着少缩进。workspace.projectTree.rows 在 compact 时多返回 depths,每行一个:节点 depth 减去它上面与唯一子文件夹合并的文件夹数。补一个链套链的 fixture。
| let row = row_path(path) | ||
| .or_else(|| ancestors(path).find_map(&row_path)) | ||
| .unwrap_or_default(); | ||
| if row != path { | ||
| selection.selected = Some(row.to_string()); | ||
| } |
There was a problem hiding this comment.
🟡 Compacted folder marks resist toggling
When a marked folder joins its only child, row_path moves the selection to the child but leaves the mark behind. Toggle matches exact paths, so Cmd/Ctrl-clicking the compact row again leaves the folder in the batch.
Learn more
The project tree and row-selection contracts use row paths as selection identities. When a chain forms, the project tree changes the visible row path to the last folder but retains the original mark and anchor because the original folder is still loaded. Toggle and Extend use exact row paths, so Toggle adds the last folder instead of removing the original mark, and Extend cannot use an anchor at the start of a visible chain. Batch targets suppress a marked descendant when its ancestor is still marked, leaving the original folder in the batch.
Example: Cmd/Ctrl-click the unlisted src folder, then expand it to discover its only child, src/main. Cmd/Ctrl-click the resulting src/main row to unmark it. The reducer instead retains src and adds src/main, and the batch still targets src.
Recommended fix: Use the compact row mapping for mark and anchor matching as well as for focus. If batch targets must retain the original filesystem paths, keep that identity separate and remove its mark when the corresponding visible row is toggled off. Add a fixture that carries the selection from a toggle through a listing that forms a chain and into a second toggle.
Was this helpful? React with 👍 or 👎 to provide feedback.
关联 Issue:1lck/Lithe-IDEA#2641(树层级太深,单一子文件夹自动折叠)
类型:feat
改动
参照 IntelliJ IDEA 的 “Compact Middle Packages” 和 VS Code 的
explorer.compactFolders:只含一个子文件夹的文件夹和它的子文件夹显示成一行,名称用/连接(例如main/java/com)。分隔符只用/;Java 包的.写法属于语言知识,应由插件负责,Core 和宿主都不处理。workspace.projectTree.rowscompact;节点新增可选字段folder(是文件夹)和listed(宿主已列出子项)。compact后,满足以下条件的文件夹和唯一的子文件夹共用一行:不是根、已经列出、唯一的已加载子项是文件夹。这一行是链上的最后一个文件夹。heads,每行一个值,表示链首(链上第一个文件夹)在nodes里的位置;行是否展开只看链首的open。depths,每行一个值,表示这一行的缩进层级:节点depth减去它上面与唯一子文件夹合并的文件夹数。一条链不管多长只占一层,链下的文件和文件夹跟着少缩进。top落在链中的文件夹上时,移到这条链所在的行,并用selectionMoved标出。compact时行为不变,响应里也没有heads和depths。git.changedFileGroupsnest: { compact? }。开启后,变更文件的所有上级文件夹(包括自身没有文件的)都会按原顺序列出,每项新增depth(第几层文件夹行)和label(这一行显示的文字)。compact: true时,不是顶层、自身没有文件、只含一个文件夹的文件夹会被省略,它的行交给子文件夹,label用/连接整条链。nest时输出不变,depth和label都不出现。以前宿主 Go 端负责拼中间文件夹和计算深度(appendFolders),这部分树投影改由 Core 负责。其他
rust/fixtures/workspace/project-tree-rows-v1.json新增 6 个用例(含链套链的缩进层级),rust/fixtures/git/changed-file-groups-v1.json新增 3 个用例。rust/contracts/rust-core-api.md补充了两个命令的新字段。crates/project/src/name_ranking.rs在 Rust 1.100 下的clippy::question_mark(feat(search): support qualified symbol matching in workspace.rankNames and workspace.symbolQuery #255 引入)。只要lithe-core在受影响列表里,这个问题就会让 clippy 失败。验证
cargo test -p lithe-core -p lithe-project -p lithe-git -p lithe-project-tree:全部通过(lithe-core 975 个)cargo clippy -p lithe-git -p lithe-project-tree -p lithe-project -p lithe-core --all-targets -- -D warnings:通过scripts/rust-core/verify-rust-core-comments.sh、node scripts/rust-core/verify-platform-tests.mjs:通过桌面端接入在 Lithe-IDEA 的配套 Draft PR 中(会临时固定本 PR 的 head)。